﻿<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="BizControl.Presentation.ActivitiesModule.Views.ActivitiesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:viewmodels="clr-namespace:BizControl.Presentation.ActivitiesModule.ViewModels"
             x:Name="ActivitiesControl">

    <UserControl.Resources>
        <DataTemplate x:Key="ActivitiesListBoxTemplate">
            <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource BorderLightBrush}"
                    Background="{Binding Path=State, Converter={StaticResource ActivityStateToBrushConverter}}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="130" />
                        <ColumnDefinition Width="140" />
                        <ColumnDefinition Width="130" />
                        <ColumnDefinition Width="100" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="{Binding Path=ShortenDescription}" TextWrapping="Wrap"
                               VerticalAlignment="Center" />
                    <ProgressBar Style="{StaticResource ProgressBarWithText}" Grid.Column="2" Height="20" 
                                 VerticalAlignment="Center" HorizontalAlignment="Stretch"
                                 ToolTip="Прогресс задачи"
                                 Value="{Binding Path=Progress, Mode=OneWay}" />
                    <Button Grid.Column="3" HorizontalAlignment="Center" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                            Width="25" Height="25" ToolTip="Редактировать задачу" Content="..."
                            Command="{Binding ElementName=ActivitiesControl, Path=DataContext.EditActivityCommand}"
                            CommandParameter="{Binding Path=Id}">
                    </Button>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="*" />
            <RowDefinition Height="200" />
        </Grid.RowDefinitions>
        <ToolBar>
            <Button HorizontalAlignment="Left" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Width="25" Height="25" ToolTip="Обновить список"
                    Command="{Binding Path=RefreshListCommand}">
                <Button.Content>
                    <Image Source="{DynamicResource refreshImage}" />
                </Button.Content>
            </Button>
            <Button HorizontalAlignment="Left" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Width="25" Height="25" ToolTip="Добавить задачу"
                    Command="{Binding Path=AddActivityCommand}"
                    Template="{StaticResource AddButtonTemplate}">
            </Button>
            <Button HorizontalAlignment="Left" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Command="{Binding Path=GoBackCommand}"
                    Content="GoBackTest">
            </Button>
            <Button HorizontalAlignment="Left" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Command="{Binding Path=CopyCommand}" CommandParameter="{Binding ElementName=ActivitiesListBox, Path=SelectedValue}"
                    Content="Копировать">
            </Button>
        </ToolBar>
        <Grid Grid.Row="1" Background="{StaticResource BackgroundBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300" />
                <ColumnDefinition Width="130" />
                <ColumnDefinition Width="140" />
                <ColumnDefinition Width="130" />
                <ColumnDefinition Width="100" />
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" BorderThickness="0,0,1,0" BorderBrush="{StaticResource SolidBorderBrush}">
                <TextBlock Text="Описание задачи" FontWeight="Bold" VerticalAlignment="Center" />
            </Border>
            <Border Grid.Column="1" BorderThickness="0,0,1,0" BorderBrush="{StaticResource SolidBorderBrush}">
                <TextBlock Text="Приоритет задачи" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />
            </Border>
            <Border Grid.Column="2" BorderThickness="0,0,1,0" BorderBrush="{StaticResource SolidBorderBrush}">
                <TextBlock Text="Прогресс задачи" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
            </Border>
        </Grid>
        <ListBox Grid.Row="2"
                 Style="{StaticResource DefaultListBoxStyle}"
                 ItemsSource="{Binding Path=Model}"
                 SelectedValue="{Binding Path=SelectedActivity, Mode=TwoWay}"
                 ItemTemplate="{StaticResource ActivitiesListBoxTemplate}"
                 Name="ActivitiesListBox" />
        <telerik:RadScheduleView Grid.Row="3" Name="scheduleView" AppointmentsSource="{Binding Appointments}">
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:TimelineViewDefinition />
                <telerik:WeekViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
        </telerik:RadScheduleView>
    </Grid>
</UserControl>
